{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "olHPiJxgKZwE",
        "outputId": "f3ba0a81-e926-4fee-b274-3359a3bb5dac"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "网络输出： 1.22\n"
          ]
        }
      ],
      "source": [
        "import numpy as np\n",
        "\n",
        "# 输入\n",
        "x = np.array([[1], [2]])  # 2x1列向量\n",
        "\n",
        "# 隐藏层参数\n",
        "W1 = np.array([[0.1, 0.2],\n",
        "               [0.3, 0.4]])  # 2x2\n",
        "b1 = np.array([[0.1],\n",
        "               [0.1]])       # 2x1\n",
        "\n",
        "# 输出层参数\n",
        "W2 = np.array([[0.5, 0.6]])  # 1x2\n",
        "b2 = np.array([[0.2]])       # 1x1\n",
        "\n",
        "# 激活函数 ReLU\n",
        "def relu(z):\n",
        "  return np.maximum(0, z)\n",
        "\n",
        "# 前向传播\n",
        "z1 = np.dot(W1, x) + b1\n",
        "a1 = relu(z1)\n",
        "z2 = np.dot(W2, a1) + b2\n",
        "output = z2\n",
        "\n",
        "print(\"网络输出：\", output[0,0])\n"
      ]
    }
  ]
}